﻿@{
    ViewBag.Title = "Danh sách chuyến bay";
}

@section PageScripts
{
    <!-- DataTables CSS -->
    <link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css">

    <!-- DataTables -->
    <script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script>

    <script type="text/javascript">
        $(document).ready(function(){
            $('#airplane-table').dataTable();
            });
    </script>
}

@model G15_Agent.Models.ViewModels.AirplaneListViewModel
           
@if (Model.dsChuyenBay != null)
{
    TempData["DanhSachChuyenBay"] = Model;
    Html.DisplayFor(m=>m.soLuongHanhKhach);
    Html.DropDownListFor(m => m.soLuongHanhKhach, Model.optionSoLuong);
    <table id="airplane-table" class="table table-striped table-condensed table-hover">    
        <thead>
            <tr>
                <th>Khởi hành</th>
                <th>Đến</th>
                <th>Thông tin chuyến bay</th>
                <th>Giá vé</th>
                <th></th>
            </tr>
        </thead>
    
        <tbody>
            @*@for (int i = 0; i < Model.dsChuyenBay.Count; i++)*@
            @foreach(var item in Model.dsChuyenBay)
            {
                using (Html.BeginForm("AirplaneSelect", "Airplane", 
                    new { serviceID = Model.serviceID, id = item.maChuyenBay, soLuong = Model.soLuongHanhKhach}, FormMethod.Post))
                {
                    @Html.HiddenFor(m => m.dsChuyenBay)                    
                    <tr>
                        <td>
                            <p>@item.maSanBayDi</p>
                            <p>@item.gioDi</p>
                        </td>
                        <td>
                            <p>@item.maSanBayDen</p>
                            <p>@item.gioDen</p>
                        </td>
                        <td>@item.maChuyenBay</td>
                        <td>@item.giaVe @item.donViTien</td>
                        <td>@Html.ActionLink("Chọn chuyến bay", "AirplaneSelect", 
                        new { serviceID = Model.serviceID, id = item.maChuyenBay, soLuong = Model.soLuongHanhKhach })</td>
                        <td><input type="submit" value="Chọn chuyến bay" /></td>
                    </tr>
                }                
            }
        </tbody>
    </table>
}
else
{
    <p>Không tìm thấy chuyến bay theo điều kiện đã cho</p>
}